/*eslint no-console:0 */
// var webpack = require('webpack');
// var WebpackDevServer = require('webpack-dev-server');
// var config = require('./webpack.config');
// var open = require('open');
//
// new WebpackDevServer(webpack(config), config.devServer)
// .listen(config.port, 'localhost', function(err) {
//   if (err) {
//     console.log(err);
//   }
//   console.log('Listening at localhost:' + config.port);
//   console.log('Opening your system browser...');
//   open('http://localhost:' + config.port + '/webpack-dev-server/');
// });

var webpack = require('webpack');
var express = require('express');
var path = require('path');
var app = express();

var config = require('./webpack.config');
var compiler = webpack(config);

require('./server/server.js');

app.use(require('webpack-dev-middleware')(compiler, {
      noInfo: true,
      publicPath: config.output.publicPath
  }));

app.use(require('webpack-hot-middleware')(compiler));


app.get('/', function(req, res) {
  res.sendFile(path.join(__dirname, 'src/index.html'));
});

app.get('/login', function(req, res) {
  res.sendFile(path.join(__dirname, 'src/login.html'));
});

app.listen(config.port, 'localhost', function(err) {
  if (err) {
    console.log(err);
    return;
  }
  console.log('Listening at localhost:'+config.port);
});
